{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Human Strategy\n",
    "----------------"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The human strategy is a strategy which asks the user to input a move rather than deriving its own action.\n",
    "The history of the match is also shown in the terminal, thus you will be able to keep track of what has happened."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We are now going to open an editor. There we are going to create a script that creates a match between a randomly selected strategy from the `axelrod` library and the human strategy. Our script will look similar to this:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "```python\n",
    "import axelrod as axl\n",
    "import random\n",
    "\n",
    "strategies = [s() for s in axl.strategies]\n",
    "opponent = random.choice(axl.strategies)\n",
    "me = axl.Human(name='Nikoleta')\n",
    "players = [opponent(), me]\n",
    "\n",
    "# play the match and return winner and final score\n",
    "match = axl.Match(players, turns=3)\n",
    "match.play()\n",
    "\n",
    "print('You have competed against {}, the final score of the match is:{} and the winner was {}'.format(opponent.name, match.final_score(),match.winner()))\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Exercise\n",
    "--------\n",
    "\n",
    "Using the script that was described above:\n",
    "\n",
    "- create a `Human()` player with your name\n",
    "- play against various opponents and write down your scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Human script (Optional)\n",
    "-----------------------"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A script that calls the `Human()` strategy and creates a match using a random generated opponent has already been written (`human.py`). For now we will have to move to a terminal.\n",
    "\n",
    "Once you have opened your terminal activate the `game-python` environment and you can now type the following command:\n",
    "\n",
    "`$ python human.py -h`\n",
    "\n",
    "This will output some information about the script."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can see the script allows the following arguments:\n",
    "\n",
    "      -n NAME           The name of the human strategy [default: me]\n",
    "      -t TURNS          The number of turns [default: 5]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we run the script. Try typing the following command:\n",
    "\n",
    "`$ python human.py -n Human -t 3`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once we run the command you will be prompted for the action to play at each turn:\n",
    "\n",
    "        Starting new match\n",
    "        Turn 1 action [C or D] for Human: C\n",
    "\n",
    "        Turn 1: me played C, opponent played C\n",
    "        Turn 2 action [C or D] for Human: D\n",
    "\n",
    "        Turn 2: me played D, opponent played C\n",
    "        Turn 3 action [C or D] for Human: C\n",
    "        \n",
    "        You have competed against Prober, the final score of the match is: (8, 8) and the winner was False"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The script will automatically output the name of your opponent, the final score and the winner of the match."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Note**: You might have a different opponent name, that is because the script randomly picks a player and\n",
    "the winner is False because it is a draw."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Summary\n",
    "--------\n",
    "\n",
    "This section has discussed:\n",
    "\n",
    "- The human strategy and how we can compete against the strategies of the library."
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
